﻿using System;

namespace EnumConversionExample
{
    class Program
    {
        enum Season
        {
            Spring,
            Summer,
            Autumn,
            Winter
        }
        static void Main(string[] args)
        {

            Season a = Season.Autumn; //定义枚举变量a
            Console.WriteLine($"枚举变量 {a} 的数值为 {(int)a}");
            //枚举量转为数值
            // 输出：枚举变量 Autumn 的数值为2

            //数值转为枚举量
            int i = 1;
            Season b = (Season)i;
            Console.WriteLine("数值{0}的枚举值为{1}",i,b.ToString());  // 输出: Summer
        }
    }
}
